#pragma once

#include <string>
#include <memory>
#include <functional>
#include <algorithm>
#include <sstream>

#include "GcovTypeDefine.hpp"

namespace wxlsx
{
    struct ExcelUtInfo
    {
        std::string className;
        std::string methodName;
        std::string outputFileName;
        int caseNumber;
        double linesExecuted;
        double branchesExecuted;
        std::string funcInCount = "1";
        std::string funcOutCount = "1";

        gcov::XmlCaseInfoList xmlCaseInfoList;

        std::string toString() const
        {
            std::ostringstream oss;

            oss << "className: " << className << ", methodName: " << methodName << ", outputFileName: " << outputFileName
                << ", caseNumber: " << caseNumber << ", linesExecuted: " << linesExecuted << ", branchesExecuted"
                << ", funcInCount: " << funcInCount << ", funcOutCount: " << funcOutCount;

            xmlCaseInfoList.foreach ([&](std::shared_ptr<gcov::XmlCaseInfo> info) -> void
                                     { oss << "{" << info->toString() << "}"; });

            return oss.str();
        };
    };

    class ExcelUtInfoList : public std::vector<std::shared_ptr<wxlsx::ExcelUtInfo>>
    {
    public:
        inline void foreach (std::function<void(std::shared_ptr<ExcelUtInfo> info)> func)
        {
            std::for_each(begin(), end(), [&](std::shared_ptr<ExcelUtInfo> info) -> void
                          { func(info); });
        };
    };

} // namespace wxlsx